<?php
class M_main extends Nvl_Model{

	function get_menus(){
		$refs = array();
		$list = array();
		$query = $this->db->order_by('menu_order')->get('s_menu');
		$result = $query->result_array();
		foreach($result AS $sub_results){
			$thisref = &$refs[ $sub_results['menu_id'] ];
			$thisref['menu_parent'] = $sub_results['menu_parent'];
			$thisref['menu_nama'] = $sub_results['menu_nama'];
			$thisref['menu_link'] = $sub_results['menu_link'];
			$thisref['menu_icon'] = $sub_results['menu_icon'];
			if($sub_results['menu_parent'] == 0){
				$list[ $sub_results['menu_id'] ] = &$thisref;
			}else{
				$refs[ $sub_results['menu_parent'] ]['children'][ $sub_results['menu_id'] ] = &$thisref;
			}
		}
		return $list;
	}
}